define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");
	var service = require('../js/service');
	
	var Model = function(){
		this.callParent();
	};

	Model.prototype.modelParamsReceive = function(event){
		var note = event.params.data;
		if (note) {
			var data = this.comp("notesData");
			data.clear();
			data.newData({
				defaultValues:[note]
			});
		} else {
			justep.Util.hint('参数错误');
			justep.Shell.closePage();
		}
	};

	Model.prototype.okBtnClick = function(event){
		var data = this.comp("notesData");
		service.updateNote({
			id: data.val('id'),
			title: data.val('title'),
			detail: data.val('detail')
		});
	};

	return Model;
});